package com.train.daily.facade.admin;

import cn.hutool.core.bean.BeanUtil;
import com.train.common.group.QueryGroup;
import com.train.common.resp.CommonResp;
import com.train.common.resp.PageResp;
import com.train.daily.dto.seat.DailyTrainSeatPageDTO;
import com.train.daily.req.seat.DailyTrainSeatPageReq;
import com.train.daily.resp.seat.DailyTrainSeatPageResp;
import com.train.daily.service.DailyTrainSeatService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * dailyTrainSeat Facade 实现类
 * @author baitiaojun
 * @createDate 2025-03-01 23:55:05
 */
@RestController("adminDailyTrainSeatFacade")
@RequiredArgsConstructor
@RequestMapping("/admin/train-seat")
public class DailyTrainSeatFacade {

    private final DailyTrainSeatService dailyTrainSeatService;

    @PostMapping("page")
    public CommonResp pageList(@RequestBody @Validated(QueryGroup.class) DailyTrainSeatPageReq req) {
        DailyTrainSeatPageDTO dailyTrainSeatPageDTO = BeanUtil.copyProperties(req, DailyTrainSeatPageDTO.class);
        PageResp<DailyTrainSeatPageResp> pageResp = dailyTrainSeatService.pageList(dailyTrainSeatPageDTO);
        return CommonResp.ok(pageResp);
    }

    @DeleteMapping("remove/{id}")
    public CommonResp delete(@PathVariable("id") Long id) {
        dailyTrainSeatService.remove(id);
        return CommonResp.ok();
    }
}
